#ifndef SESSIONFRIENDAREA_H
#define SESSIONFRIENDAREA_H

#include <QScrollArea>
#include <QScrollBar>
#include <QVBoxLayout>
#include <QPushButton>
#include <QLabel>
#include "debug.h"
#include <QIcon>
#include <QStyleOption>
#include <QPainter>
#include "model/data.h"

enum ItemType{
    SessionItemType,
    FriendItemType,
    ApplyItemType
};

///////////////////////////
/// 会话区域
//////////////////////////
class SessionFriendArea : public QScrollArea
{
public:
    explicit SessionFriendArea(QWidget *parent = nullptr);
    void addItem(ItemType itemType, const QString& itemId, const QIcon& avatar, const QString& name, const QString& text);
    void clickItem(int index);



private:
    QWidget* container;
signals:
};


////////////////////////
/// 会话区域中的Item块
////////////////////////////

class SessionFriendItem : public QWidget{
    Q_OBJECT
public:

    SessionFriendItem(QWidget* owner, const QIcon& avatar, const QString& name, const QString& text);
    void mousePressEvent(QMouseEvent *event);
    void enterEvent(QEnterEvent *event);
    void leaveEvent(QEvent *event);
    void paintEvent(QPaintEvent *event);
    void select();

private:
    bool selected = false;

protected:
    QLabel *messageLabel;
};


////////////////////////
/// 会话Item
////////////////////////////

class SessionItem : public SessionFriendItem {
    Q_OBJECT

public:
    SessionItem(QWidget* owner, const QString& sessionId, const QIcon& avatar,
                const QString& name, const QString& lastMessage);
    ~SessionItem();

private:
    QString _sessionId;

    QString _lastMessage;
};


////////////////////////
/// 好友Item
////////////////////////////

class FriendItem : public SessionFriendItem {
    Q_OBJECT

public:
    FriendItem(QWidget* owner, const QString& userId, const QIcon& avatar,
                const QString& name, const QString& description);
    ~FriendItem();

private:
    QString _userId;

};

////////////////////////
/// 好友申请Item
////////////////////////////

class ApplyItem : public SessionFriendItem {
    Q_OBJECT

public:
    ApplyItem(QWidget* owner, const QString& applyId, const QIcon& avatar, const QString& name);
    ~ApplyItem();

private:
    QString _applyId;
};


#endif // SESSIONFRIENDAREA_H
